package com.rainner.app.action;

import java.sql.SQLException;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.rainner.app.base.action.JsonAction;
import com.rainner.app.server.BookServer;
@Results({ 
	@Result(type = "freemarker", name = "INDEX", location = "/WEB-INF/content/index.ftl"),
	})
public class IndexAction extends JsonAction{
	private static final long serialVersionUID = 1L;
	private BookServer bookServer = new BookServer();
	@Action("/index")
	public String index() throws SQLException {
		//日期排序前三本书为推荐书籍
		map.put("tjsj", bookServer.allBookData(null,null,0));
		//判断用户是否登录
		HttpSession session = ServletActionContext.getRequest().getSession();
		//session.setAttribute("username", "wuhao");
		map.put("username", session.getAttribute("username"));
		return "INDEX";
	}
	
	
}
